﻿using Crap4Net;
using System;
using NUnit.Framework;

namespace Crap4Net.UnitTests.EntitiesTests
{
    [TestFixture]
    public class CCDataEntryTest
    {
        readonly MethodSignature _method = new MethodSignature("dll1", "ns", "SomeClass", "SomeMethod", new string[] { });
        readonly MethodSignature _AnotherMethod = new MethodSignature("dll1", "ns", "SomeOtherClass", "SomeMethod", new string[] { });
        

        [Test()]
        public void Equals_IdenticalValues_ReturnTrue()
        {
            CCDataEntry target1 = new CCDataEntry(_method, 1);
            CCDataEntry target2 = new CCDataEntry(_method, 1);
            Assert.IsTrue(target1.Equals(target2));
        }


        [Test()]
        public void Equals_DifferentMethod_ReturnFalse()
        {
            CCDataEntry target1 = new CCDataEntry(_method, 1);
            CCDataEntry target2 = new CCDataEntry(_AnotherMethod, 1);
            Assert.IsFalse(target1.Equals(target2));
        }

        [Test()]
        public void Equals_DifferentCCValue_ReturnFalse()
        {
            CCDataEntry target1 = new CCDataEntry(_method, 1);
            CCDataEntry target2 = new CCDataEntry(_method, 2);
            Assert.IsFalse(target1.Equals(target2));
        }

        [Test()]
        public void Equals_NullValue_ReturnFalse()
        {
            CCDataEntry target = new CCDataEntry(_method, 1);
            bool actual = target.Equals(null);
            Assert.IsFalse(actual);
        }

        [Test()]
        public void ctor_LegalValue_InitializeFields()
        {
            CCDataEntry target = new CCDataEntry(_method, 5);
            Assert.AreEqual(5, target.CyclomaticComplexity);
            Assert.AreEqual(_method, target.Method);

        }

        [Test()]
        [ExpectedException(typeof(ArgumentException))]
        public void ctor_NegativeCCValue_ThrowsException()
        {
            CCDataEntry target = new CCDataEntry(_method, -1);
        }
    }
}
